import type {PageParam, PageResult} from '@vben/request';
import type {Dayjs} from 'dayjs';

import {requestClient} from '#/api/request';
export namespace PerBusinessFamilyInvestmentApi {
  /** 国境外投资信息业务信息 */
  export interface BusinessFamilyInvestment {
    id: number; // 主键ID
    busiId?: string; // 业务主表id
    familyInvestmentId: number; // 正式表ID，对应 per_family_investment.id
    employeeId?: number; // 人员ID，对应 per_employee.id
    relation: string; // 与本人关系（称谓）
    systemPersonId: number; // 系统人员ID，对应 system_person.id
    familyName: string; // 投资人姓名
    cardType: string; // 证件类型
    familyIdcard: string; // 投资人身份证号
    investmentUnit: string; // 投资或入股单位
    countryCity: string; // 投资的国家地区及城市
    investmentMethod: string; // 投资或入股方式
    position: string; // 担任职务
    investmentDetails: string; // 投资情况
    currency: string; // 投资币种
    amountInvested: number; // 出资金额
    amountRmb: number; // 人民币金额
    annualReturn: number; // 年收益
    remark: string; // 备注
    status: number; // 状态（1：有效，0：无效）
    changeType: string; // 变更类型（add：新增，update：修改，delete：删除）
    changeContent: string; // 变更内容(JSON格式，记录变更前后对比，只有修改的时候记录)
    auditStatus: number; // 审核状态（0 草稿 1 审核中 2 审核完成）
    finalAuditStatus: number; // 最终审核状态：0 待审核 1 审核通过 2 审核不通过
    auditTime: string | Dayjs; // 审核完成时间
    auditor: string; // 审核人
    auditComment: string; // 审核意见
    metadata: string; // 其他参数
  }
}

/** 查询国境外投资信息业务分页 */
export function getBusinessFamilyInvestmentPage(data: PageParam,desensitize: boolean,encrypt: boolean) {
  return requestClient.post<PageResult<PerBusinessFamilyInvestmentApi.BusinessFamilyInvestment>>('/per/business-family-investment/page', data,{ desensitize,encrypt });
}

/** 查询国境外投资信息业务详情 */
export function getBusinessFamilyInvestment(id: number) {
  return requestClient.get<PerBusinessFamilyInvestmentApi.BusinessFamilyInvestment>(`/per/business-family-investment/get?id=${id}`);
}

/** 新增国境外投资信息业务 */
export function createBusinessFamilyInvestment(data: PerBusinessFamilyInvestmentApi.BusinessFamilyInvestment) {
  return requestClient.post('/per/business-family-investment/create', data);
}

/** 修改国境外投资信息业务 */
export function updateBusinessFamilyInvestment(data: PerBusinessFamilyInvestmentApi.BusinessFamilyInvestment) {
  return requestClient.put('/per/business-family-investment/update', data);
}

/** 删除国境外投资信息业务 */
export function deleteBusinessFamilyInvestment(id: number) {
  return requestClient.delete(`/per/business-family-investment/delete?id=${id}`);
}

/** 批量删除国境外投资信息业务 */
export function deleteBusinessFamilyInvestmentList(ids: number[]) {
  return requestClient.delete(`/per/business-family-investment/delete-list?ids=${ids.join(',')}`)
}

/** 导出国境外投资信息业务 */
export function exportBusinessFamilyInvestment(params: any) {
  return requestClient.download('/per/business-family-investment/export-excel', { params });
}

/** 根据业务主表id去查询业务数据 */
export function getFamilyInvestmentBusiId(data: any) {
  return requestClient.post<PerBusinessFamilyInvestmentApi.BusinessFamilyInvestment>(
    `/per/business-family-investment/getFamilyInvestmentBusiId`,
    data,
  );
}

/** 获取当前登录人国境外投资信息 */
export function getCurrentFamilyInvestment(
  data: any,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<PerBusinessFamilyInvestmentApi.BusinessFamilyInvestment[]>(
    '/per/business-family-investment/getCurrentFamilyInvestment',
    data,
    {
      desensitize,
      encrypt,
    },
  );
}
